const baseurl = "http://192.168.1.108:3000"

function req(url, data, type = 'get') {
	return new Promise((resolve, reject) => {
		uni.request({
			//请求带上cookie
			url: baseurl + url+`${uni.getStorageSync('cookie')==''?'':`?cookie=${encodeURIComponent(uni.getStorageSync('cookie'))}`}`,
			data: data,
			method: type,
			success(res) {
				resolve(res.data);
			},
			fail(err) {
				uni.showToast({
					title: "网络繁忙请重试",
					icon: 'none'
				});
				reject(err)
			}
		})
	})
}

module.exports = {
	baseurl,
	req
}
